package com.ly.demo.bean;

import com.ly.demo.entity.SmResult;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;

import java.util.LinkedHashMap;
import java.util.Map;

/**
 * @Author liuyang
 * @Date 2023/6/26 15:40
 **/
@Aspect
@Component
public class MyAspect {

    //@Around("execution(* com.ly.demo.controller.*.*(..))")
    public Object around(ProceedingJoinPoint joinPoint) throws Throwable {
        // 在目标方法执行前的自定义操作
        System.out.println("Before executing the method");

        // 执行目标方法
        Object result = joinPoint.proceed();

        // 在目标方法执行后的自定义操作
        System.out.println("After executing the method");

        // 返回结果
        return result;
    }

    public static void main(String[] args) {
        int[] nums = {-2,1,-3,4,-1,2,1,-5,4};
        if (nums == null || nums.length == 0) {
            return ;
        }

        int[] tm = new int[nums.length];
        tm[0] = nums[0];
        int maxSum = tm[0];

        for (int i = 1; i < nums.length; i++) {
            tm[i] = Math.max(nums[i], tm[i-1] + nums[i]);
            maxSum = Math.max(maxSum, tm[i]);
        }
        System.out.println(maxSum);
    }
}

